package com.example.demo.controller.people;

import com.example.demo.dao.people.EmployeeDAO;
import com.example.demo.model.ResponseMessage;
import com.example.demo.model.people.Employee;
import com.example.demo.model.system.Dict;
import com.example.demo.model.system.User;
import com.example.demo.service.people.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService service;

    @RequestMapping("getByEmployeeDept")
    List<Employee> getByEmployeeDept(Integer employee_dept){return service.getByEmployeeDept(employee_dept);}

    @RequestMapping("save")
    public ResponseMessage save(Employee employee){
        ResponseMessage responseMessage = new ResponseMessage();
        Boolean flag = service.save(employee);
        responseMessage.setFlag(flag);

        return  responseMessage;
    }

    @RequestMapping("selectAll")
    public List<Employee> selectAll(){return service.selectAll();}

    @RequestMapping("addEmployee")
    public Integer addEmployee(Employee employee){return service.addEmployee(employee);}

    @RequestMapping("deleteById")
    public Boolean deleteById(Integer employee_id){return service.deleteById(employee_id)==1;}

    @RequestMapping("updateById")
    public Integer updateById(Employee employee){return service.updateById(employee);}

    @RequestMapping("findEmployee")
    public List<Employee> findEmployee(String  employee_name,Integer employee_dept) {return service.findEmployee(employee_name,employee_dept);}

}
